// 提交订单接口
import instance from '@/utils/request'
import store from '@/store'
// 订单结算页面展示获取
export const submitOrder = (mode, obj) => {
  const token = store.getters.isLogin
  return instance({
    url: '/checkout/order',
    headers: {
      'Access-Token': token,
      platform: 'H5'
    },
    params: {
      mode,
      delivery: 10,
      payType: 10,
      couponId: 0,
      isUsePoints: 0,
      remark: '',
      ...obj
    }
  })
}

// 提交订单
export const submit = (mode, obj) => {
  const token = store.getters.isLogin
  return instance({
    url: '/checkout/submit',
    method: 'POST',
    headers: {
      'Access-Token': token,
      platform: 'H5'
    },
    data: {
      delivery: 10,
      couponId: 0,
      isUsePoints: 0,
      payType: 10,
      remark: '快点发货呀',
      mode,
      ...obj
    }
  })
}

// 获取我的订单
export const getMyOrder = (dataType) => {
  const token = store.getters.isLogin
  return instance({
    url: '/order/list',
    headers: {
      'Access-Token': token,
      platform: 'H5'
    },
    params: {
      dataType,
      page: 1
    }
  })
}

// 取消订单
export const cancelOrder = (orderId) => {
  const token = store.getters.isLogin
  return instance({
    url: '/order/cancel',
    method: 'POST',
    headers: {
      'Access-Token': token,
      platform: 'H5'
    },
    data: {
      orderId
    }
  })
}
